/**
 * 显示消息提示
 * @param title 提示内容
 * @param duration 提示时长
 */
export function toast(title: string, duration = 200) {
  return new Promise<void>(resolve => {
    uni.showToast({
      title,
      duration,
      complete() {
        setTimeout(() => {
          resolve();
        }, duration - 100);
      }
    });
  });
}

/**
 * 显示弹窗确认
 * @param content 弹窗内容
 * @param title 弹窗标题
 */
export function confirm(content: string, title = '提示') {
  return new Promise<void>((resolve) => {
    uni.showModal({
      title,
      content,
      success(res) {
        if (res.confirm) {
          resolve();
        }
      }
    });
  });
}
